#if (FEATURE_MODE == 0)
/**
 @file ctc_usw_dtel_cli.c

 @date 2019-07-31

 @version v2.0

---file comments----
*/

/****************************************************************
 *
 * Header Files
 *
 ***************************************************************/

#include "sal.h"
#include "ctc_cli.h"
#include "ctc_common.h"
#include "ctc_cli_common.h"
#include "ctc_const.h"
#include "ctc_api.h"
#include "ctcs_api.h"
#include "ctc_debug.h"
#include "ctc_error.h"
#include "ctc_chip.h"
#include "dal.h"

#define CTC_CLI_DTEL_MODULE     "Dtel Module"
#define CTC_CLI_INT_MODULE      "INT Module"
#define CTC_CLI_IFA_MODULE      "IFA Module"

CTC_CLI(ctc_cli_dtel_int_set_sink,
        ctc_cli_dtel_int_set_sink_cmd,
        "dtel int session-id ID {log-en|postcard-en|log-percent LOG_PERCENT|rep-md-bits BITMAP|nhid NHID|log-id ID|}",
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_INT_MODULE,
        "Session ID",
        "Session ID value",
        "Log Enable",
        "Postcard enable",
        "Log percent",
        "Log percent value",
        "Report metadata bitmap",
        "Bitmap",
        "Nhid",
        "Nexthop ID",
        "Log ID",
        "Log ID value")
{
    int32 ret = CLI_SUCCESS;
    uint8 index = 0;
    ctc_dtel_int_cfg_t int_cfg;

    sal_memset(&int_cfg, 0, sizeof(ctc_dtel_int_cfg_t));
    CTC_CLI_GET_UINT8("session id", int_cfg.session_id, argv[0]);
    index = CTC_CLI_GET_ARGC_INDEX("log-en");
    if (INDEX_VALID(index))
    {
        int_cfg.log_en = 1;
    }
    index = CTC_CLI_GET_ARGC_INDEX("rep-md-bits");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_UINT8("rep md bits", int_cfg.rep_md_bits, argv[index+1]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("nhid");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_UINT32("nhid", int_cfg.nh_id, argv[index+1]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("log-percent");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_UINT8("log percent", int_cfg.log_percent, argv[index+1]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("postcard-en");
    if (INDEX_VALID(index))
    {
        int_cfg.postcard_en = 1;
    }
    index = CTC_CLI_GET_ARGC_INDEX("log-id");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_UINT8("log id", int_cfg.log_id, argv[index+1]);
    }
    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_set_int_cfg(g_api_ldev, &int_cfg);
    }
    else
    {
        ret = ctc_dtel_set_int_cfg(&int_cfg);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return ret;
}

CTC_CLI(ctc_cli_dtel_show_int_sink,
        ctc_cli_dtel_show_int_sink_cmd,
        "show dtel int session-id ID",
        CTC_CLI_SHOW_STR,
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_INT_MODULE,
        "Session ID",
        "Session ID value")
{
    int32 ret = CLI_SUCCESS;
    ctc_dtel_int_cfg_t int_cfg;

    sal_memset(&int_cfg, 0, sizeof(ctc_dtel_int_cfg_t));
    CTC_CLI_GET_UINT8("session id", int_cfg.session_id, argv[0]);

    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_get_int_cfg(g_api_ldev, &int_cfg);
    }
    else
    {
        ret = ctc_dtel_get_int_cfg(&int_cfg);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    ctc_cli_out("%-34s:  %u\n",     "Session id", int_cfg.session_id);
    ctc_cli_out("%-34s:  %s\n",     "Log en", int_cfg.log_en? "Enable": "Disable");
    ctc_cli_out("%-34s:  %u\n",     "Log percent", int_cfg.log_percent);
    ctc_cli_out("%-34s:  %s\n",     "Postcard en", int_cfg.postcard_en? "Enable": "Disable");
    ctc_cli_out("%-34s:  0x%x\n",   "Rep md bits", int_cfg.rep_md_bits);
    ctc_cli_out("%-34s:  %u\n",     "Log id", int_cfg.log_id);
    ctc_cli_out("%-34s:  0x%x\n",   "nhid", int_cfg.nh_id);
    return ret;
}

extern int32
sys_usw_dtel_show_int_status(uint8 lchip);
CTC_CLI(ctc_cli_dtel_show_int_status,
        ctc_cli_dtel_show_int_status_cmd,
        "show dtel int status",
        CTC_CLI_SHOW_STR,
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_INT_MODULE,
        "Status"
        )
{
    int32  ret = CLI_SUCCESS;

    ret = sys_usw_dtel_show_int_status(g_api_lchip);

    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return ret;
}

CTC_CLI(ctc_cli_dtel_debug_on,
        ctc_cli_dtel_debug_on_cmd,
        "debug dtel int (ctc | sys) (debug-level {func|param|info|error} |)",
        CTC_CLI_DEBUG_STR,
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_INT_MODULE,
        "Ctc layer",
        "Sys layer",
        CTC_CLI_DEBUG_LEVEL_STR,
        CTC_CLI_DEBUG_LEVEL_FUNC,
        CTC_CLI_DEBUG_LEVEL_PARAM,
        CTC_CLI_DEBUG_LEVEL_INFO,
        CTC_CLI_DEBUG_LEVEL_ERROR)
{
    uint32 typeenum = 0;
    uint8 level = CTC_DEBUG_LEVEL_INFO;
    uint8 index = 0;

    index = CTC_CLI_GET_ARGC_INDEX("debug-level");
    if (index != 0xFF)
    {
        level = CTC_DEBUG_LEVEL_NONE;
        index = CTC_CLI_GET_ARGC_INDEX("func");
        if (index != 0xFF)
        {
            level |= CTC_DEBUG_LEVEL_FUNC;
        }

        index = CTC_CLI_GET_ARGC_INDEX("param");
        if (index != 0xFF)
        {
            level |= CTC_DEBUG_LEVEL_PARAM;
        }

        index = CTC_CLI_GET_ARGC_INDEX("info");
        if (index != 0xFF)
        {
            level |= CTC_DEBUG_LEVEL_INFO;
        }

        index = CTC_CLI_GET_ARGC_INDEX("error");
        if (index != 0xFF)
        {
            level |= CTC_DEBUG_LEVEL_ERROR;
        }
    }
    else
    {
        level = CTC_DEBUG_LEVEL_FUNC | CTC_DEBUG_LEVEL_INFO | CTC_DEBUG_LEVEL_PARAM | CTC_DEBUG_LEVEL_ERROR;
    }

    if (0 == sal_memcmp(argv[0], "ctc", 3))
    {
        typeenum = DTEL_CTC;
    }
    else if (0 == sal_memcmp(argv[0], "sys", 3))
    {
        typeenum = DTEL_SYS;
    }

    ctc_debug_set_flag("dtel", "dtel", typeenum, level, TRUE);

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_debug_off,
        ctc_cli_dtel_debug_off_cmd,
        "no debug dtel int (ctc | sys)",
        CTC_CLI_NO_STR,
        CTC_CLI_DEBUG_STR,
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_INT_MODULE,
        "Ctc layer",
        "Sys layer")
{
    uint32 typeenum = 0;
    uint8 level = 0;

    if (0 == sal_memcmp(argv[0], "ctc", 3))
    {
        typeenum = DTEL_CTC;
    }
    else if (0 == sal_memcmp(argv[0], "sys", 3))
    {
        typeenum = DTEL_SYS;
    }

    ctc_debug_set_flag("dtel", "dtel", typeenum, level, FALSE);

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_set_int_cfg,
        ctc_cli_dtel_set_int_cfg_cmd,
        "dtel int (int-en |ts-gran |rep-len |sink-len |remain-hop |remain-hop-cnt | lv2-port-mode) (value VALUE) ",
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_INT_MODULE,
        "enable INT",
        "time granularity",
        "report length",
        "sink length",
        "remain hop threshold",
        "remain hop count",
        "lv2 port mode",
        "Value",
        "Value")
{
    int32 ret = CLI_SUCCESS;
    uint8 index = 0;

    ctc_dtel_property_t type;
    uint32 value =0;

    sal_memset(&type, 0, sizeof(ctc_dtel_property_t));
    sal_memset(&type, 0, sizeof(ctc_dtel_int_lv2_port_mode_t));


    index = CTC_CLI_GET_ARGC_INDEX("int-en");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_EN;
        CTC_CLI_GET_UINT8("int-en", value, argv[index+2]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("ts-gran");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_TS_GRAN;
        CTC_CLI_GET_UINT32("ts-gran", value, argv[index+2]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("rep-len");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_REP_LEN_THRD;
        CTC_CLI_GET_UINT32("report-len", value, argv[index+2]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("sink-len");
    if (INDEX_VALID(index))
    {
       type = CTC_DTEL_INT_SINK_LEN_THRD;
       CTC_CLI_GET_UINT32("sink-len", value, argv[index+2]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("remain-hop");
    if (INDEX_VALID(index))
    {
       type = CTC_DTEL_INT_REMAINING_HOP_THRD;
       CTC_CLI_GET_UINT32("remain-hop", value, argv[index+2]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("remain-hop-cnt");
    if (INDEX_VALID(index))
    {
       type = CTC_DTEL_INT_REMAINING_HOP_CNT;
       CTC_CLI_GET_UINT32("remain-hop-cnt", value, argv[index+2]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("lv2-port-mode");
    if (INDEX_VALID(index))
    {
       type = CTC_DTEL_INT_LV2_PORT_MODE;
       CTC_CLI_GET_UINT32("lv2-port-mode", value, argv[index+2]);
    }
    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_set_property(g_api_ldev, type,&value);
    }
    else
    {
        ret = ctc_dtel_set_property(type,&value);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return ret;
}

CTC_CLI(ctc_cli_dtel_set_int_act,
        ctc_cli_dtel_set_int_act_cmd,
        "dtel int (cbit-not-zero |rep-not-zero|exceed-sink-length |exceed-report-length|below-remain-hop) type (none|cancel|sink SESSIONID) action (forward|copy-cpu|redirect-cpu|discard)",
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_INT_MODULE,
        "C bit not equal zero",
        "Rep bit not equal zero",
        "exceed sink length",
        "exceed report length",
        "Below remain hop",
        "INT type",
        "none",
        "cancel",
        "sink",
        "sink session id",
        "Action",
        "forward",
        "copy to cpu",
        "redirect to cpu",
        "discard")
{
    int32 ret = CLI_SUCCESS;
    uint8 index = 0;

    ctc_dtel_property_t type;
    ctc_dtel_int_transmit_action_t session;

    sal_memset(&type, 0, sizeof(ctc_dtel_property_t));
    sal_memset(&session, 0, sizeof(ctc_dtel_int_transmit_action_t));

    index = CTC_CLI_GET_ARGC_INDEX("cbit-not-zero");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_CBIT_NOT_EQ_ZERO_ACTION;
    }
    index = CTC_CLI_GET_ARGC_INDEX("rep-not-zero");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_REP_NOT_EQ_ZERO_ACTION;
    }
    index = CTC_CLI_GET_ARGC_INDEX("exceed-sink-length");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_EXCEED_SINK_LEN_ACTION;
    }
    index = CTC_CLI_GET_ARGC_INDEX("exceed-report-length");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_EXCEED_REP_LEN_ACTION;
    }
    index = CTC_CLI_GET_ARGC_INDEX("below-remain-hop");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_BELOW_REMAIN_HOP_ACTION;
    }
    index = CTC_CLI_GET_ARGC_INDEX("none");
    if(INDEX_VALID(index))
    {
     session.session_type = CTC_DTEL_INT_SESSION_TYPE_NONE;
    }
    index = CTC_CLI_GET_ARGC_INDEX("cancel");
    if(INDEX_VALID(index))
    {
     session.session_type = CTC_DTEL_INT_SESSION_TYPE_CANCEL;
    }
    index = CTC_CLI_GET_ARGC_INDEX("sink");
    if(INDEX_VALID(index))
    {
     session.session_type = CTC_DTEL_INT_SESSION_TYPE_SINK;
     CTC_CLI_GET_UINT8("session-id", session.session_id, argv[index+1]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("forward");
    if(INDEX_VALID(index))
    {
     session.action = CTC_EXCP_NORMAL_FWD;
    }
    index = CTC_CLI_GET_ARGC_INDEX("copy-cpu");
    if(INDEX_VALID(index))
    {
     session.action = CTC_EXCP_FWD_AND_TO_CPU;
    }
    index = CTC_CLI_GET_ARGC_INDEX("redirect-cpu");
    if(INDEX_VALID(index))
    {
     session.action = CTC_EXCP_DISCARD_AND_TO_CPU;
    }
    index = CTC_CLI_GET_ARGC_INDEX("discard");
    if(INDEX_VALID(index))
    {
     session.action = CTC_EXCP_DISCARD;
    }

    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_set_property(g_api_ldev, type,(void*)&session);
    }
    else
    {
        ret = ctc_dtel_set_property(type,(void*)&session);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return ret;
}

CTC_CLI(ctc_cli_dtel_get_int_cfg,
        ctc_cli_dtel_get_int_cfg_cmd,
        "show dtel int (int-en|rep-len|ts-gran|sink-len |remain-hop |remain-hop-cnt |lv2-port-mode|cbit-not-zero |rep-not-zero |exceed-sink-len |exceed-rep-len|below-remain-hop) ",
        "Show",
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_INT_MODULE,
        "Enable INT",
        "Report Length Threshold",
        "TimeStamp",
        "Sink Length Threshold",
        "Remain Hop Threshold",
        "Remain Hop Count",
        "L2-Port-mode",
        "Cbit not equal zero",
        "Repbit not equal zero",
        "Exceed Sink Length",
        "Exceed report Length",
        "Below remain hop")
{
    int32 ret = CLI_SUCCESS;
    uint8 index = 0;
    uint32 value = 0;
    void* p_value = &value;
    ctc_dtel_int_transmit_action_t action;
    uint32 type = 0;

    sal_memset(&action, 0, sizeof(ctc_dtel_int_transmit_action_t));

    index = CTC_CLI_GET_ARGC_INDEX("int-en");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_EN;
    }
    index = CTC_CLI_GET_ARGC_INDEX("rep-len");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_REP_LEN_THRD;
    }
    index = CTC_CLI_GET_ARGC_INDEX("ts-gran");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_TS_GRAN;
    }
    index = CTC_CLI_GET_ARGC_INDEX("sink-len");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_SINK_LEN_THRD;
    }
    index = CTC_CLI_GET_ARGC_INDEX("remain-hop");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_REMAINING_HOP_THRD;
    }
    index = CTC_CLI_GET_ARGC_INDEX("remain-hop-cnt");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_REMAINING_HOP_CNT;
    }
    index = CTC_CLI_GET_ARGC_INDEX("lv2-port-mode");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_LV2_PORT_MODE;
    }
    index = CTC_CLI_GET_ARGC_INDEX("cbit-not-zero");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_CBIT_NOT_EQ_ZERO_ACTION;
        p_value = &action;
    }
    index = CTC_CLI_GET_ARGC_INDEX("rep-not-zero");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_REP_NOT_EQ_ZERO_ACTION;
        p_value = &action;
    }
    index = CTC_CLI_GET_ARGC_INDEX("exceed-sink-len");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_EXCEED_SINK_LEN_ACTION;
        p_value = &action;
    }
    index = CTC_CLI_GET_ARGC_INDEX("exceed-rep-len");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_EXCEED_REP_LEN_ACTION;
        p_value = &action;
    }
    index = CTC_CLI_GET_ARGC_INDEX("below-remain-hop");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_BELOW_REMAIN_HOP_ACTION;
        p_value = &action;
    }
    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_get_property(g_api_ldev, type,p_value);
    }
    else
    {
        ret = ctc_dtel_get_property(type,p_value);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    ctc_cli_out("==================== %22s ====================\n", "Dtel Global Info:");
    if(type <= CTC_DTEL_INT_LV2_PORT_MODE)
    {
        ctc_cli_out("%-34s:  %u\n",   argv[0], value);
    }
    else if (type > CTC_DTEL_INT_LV2_PORT_MODE && type <= CTC_DTEL_INT_BELOW_REMAIN_HOP_ACTION)
    {
        ctc_cli_out("%-34s:  %u\n",   "Session type", action.session_type);
        ctc_cli_out("%-34s:  %u\n",   "Session id", action.session_id);
        ctc_cli_out("%-34s:  %u\n",   "Action type", action.action);
    }
    ctc_cli_out("================================================================\n");
    return ret;
}

CTC_CLI(ctc_cli_dtel_set_tsx,
        ctc_cli_dtel_set_tsx_cmd,
        "dtel tsx type (mac-stats | drop-stats | buffer-watermark | latency-watermark | buffer-stats | latency-stats )\
        (enable | disable) (ports ("CTC_CLI_PORT_BITMAP_STR"|"CTC_CLI_PORT_BITMAP_ARRAY_STR") |) (interval INTERVAL |) (nh-id NH_ID |)",
        CTC_CLI_DTEL_MODULE,
        "Telemetry statistics export",
        "Export type",
        "Mac statistics",
        "Drop statistics",
        "Buffer watermark",
        "Latency watermark",
        "Buffer statistics",
        "Latency statistics",
        "Enable",
        "Disable",
        "Ports",
        CTC_CLI_PORT_BITMAP_DESC,
        CTC_CLI_PORT_BITMAP_VALUE_DESC,
        CTC_CLI_PORT_BITMAP_DESC,
        CTC_CLI_PORT_BITMAP_VALUE_DESC,
        CTC_CLI_PORT_BITMAP_DESC,
        CTC_CLI_PORT_BITMAP_VALUE_DESC,
        CTC_CLI_PORT_BITMAP_DESC,
        CTC_CLI_PORT_BITMAP_VALUE_DESC,
        CTC_CLI_PORT_BITMAP_DESC,
        CTC_CLI_PORT_BITMAP_VALUE_DESC,
        CTC_CLI_PORT_BITMAP_DESC,
        CTC_CLI_PORT_BITMAP_VALUE_DESC,
        CTC_CLI_PORT_BITMAP_DESC,
        CTC_CLI_PORT_BITMAP_VALUE_DESC,
        CTC_CLI_PORT_BITMAP_DESC,
        CTC_CLI_PORT_BITMAP_VALUE_DESC,
        CTC_CLI_PORT_BITMAP_DESC,
        CTC_CLI_PORT_BITMAP_VALUE_DESC,
        CTC_CLI_PORT_BITMAP_DESC,
        CTC_CLI_PORT_BITMAP_VALUE_DESC,
        CTC_CLI_PORT_BITMAP_DESC,
        CTC_CLI_PORT_BITMAP_VALUE_DESC,
        CTC_CLI_PORT_BITMAP_DESC,
        CTC_CLI_PORT_BITMAP_VALUE_DESC,
        CTC_CLI_PORT_BITMAP_ARRAY_DESC,
        "Export interval",
        "Interval Value",
        "Nexthop Id",
        "Nexthop Id Value")
{
    int32 ret = CLI_SUCCESS;
    uint8 index = 0xFF;
    ctc_dtel_tsx_cfg_t tsx_cfg;
    uint32 max_num = CTC_PORT_BITMAP_IN_WORD;

    sal_memset(&tsx_cfg, 0, sizeof(ctc_dtel_tsx_cfg_t));
    if (CLI_CLI_STR_EQUAL("mac-stats", 0))
    {
        tsx_cfg.type = CTC_DTEL_TSX_MAC_STATS;
    }
    else if (CLI_CLI_STR_EQUAL("drop-stats", 0))
    {
        tsx_cfg.type = CTC_DTEL_TSX_DROP_STATS;
    }
    else if (CLI_CLI_STR_EQUAL("buffer-watermark", 0))
    {
        tsx_cfg.type = CTC_DTEL_TSX_BUFFER_WATERMARK;
    }
    else if (CLI_CLI_STR_EQUAL("latency-watermark", 0))
    {
        tsx_cfg.type = CTC_DTEL_TSX_LATENCY_WATERMARK;
    }
    else if (CLI_CLI_STR_EQUAL("buffer-stats", 0))
    {
        tsx_cfg.type = CTC_DTEL_TSX_BUFFER_STATS;
    }
    else if (CLI_CLI_STR_EQUAL("latency-stats", 0))
    {
        tsx_cfg.type = CTC_DTEL_TSX_LATENCY_STATS;
    }
    else
    {
        return CLI_ERROR;
    }

    if (CLI_CLI_STR_EQUAL("enable", 1))
    {
        tsx_cfg.enable = 1;
    }
    else
    {
        tsx_cfg.enable = 0;
    }
    CTC_CLI_PORT_BITMAP_GET(tsx_cfg.port_bmp);
    index = CTC_CLI_GET_ARGC_INDEX("array-bmp");
    if(index != 0xFF)
    {
    	CTC_CLI_GET_UINT32_ARRAY("array-bmp", tsx_cfg.port_bmp, &max_num, argv[index + 1], ret);
    }

    index = CTC_CLI_GET_ARGC_INDEX("interval");
    if (index != 0xFF)
    {
        CTC_CLI_GET_UINT32("interval", tsx_cfg.interval, argv[index + 1]);
    }
    index = CTC_CLI_GET_ARGC_INDEX("nh-id");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_UINT32("nh id", tsx_cfg.nh_id, argv[index + 1]);
    }
    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_set_property(g_api_ldev, CTC_DTEL_TSX_CFG,(void*)&tsx_cfg);
    }
    else
    {
        ret = ctc_dtel_set_property(CTC_DTEL_TSX_CFG,(void*)&tsx_cfg);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_set_tex,
        ctc_cli_dtel_set_tex_cmd,
        "dtel tex type (drop-event | buffer-event | latency-event) (enable nh-id NH_ID | disable)",
        CTC_CLI_DTEL_MODULE,
        "Telemetry events export",
        "Export type",
        "Packet drop event",
        "Buffer congestion event",
        "Latency congestion event",
        "Enable",
        "Nexthop Id",
        "Nexthop Id Value",
        "Disable")
{
    int32 ret = CLI_SUCCESS;
    ctc_dtel_tex_cfg_t tex_cfg;

    sal_memset(&tex_cfg, 0, sizeof(ctc_dtel_tex_cfg_t));
    if (CLI_CLI_STR_EQUAL("drop-event", 0))
    {
        tex_cfg.type = CTC_DTEL_TEX_DROP_EVENT;
    }
    else if (CLI_CLI_STR_EQUAL("buffer-event", 0))
    {
        tex_cfg.type = CTC_DTEL_TEX_BUFFER_EVENT;
    }
    else if (CLI_CLI_STR_EQUAL("latency-event", 0))
    {
        tex_cfg.type = CTC_DTEL_TEX_LATENCY_EVENT;
    }
    else
    {
        return CLI_ERROR;
    }

    if (CLI_CLI_STR_EQUAL("enable", 1))
    {
        CTC_CLI_GET_UINT32("nh id", tex_cfg.nh_id, argv[3]);
    }
    else
    {
        tex_cfg.nh_id = 0;
    }

    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_set_property(g_api_ldev, CTC_DTEL_TEX_CFG,(void*)&tex_cfg);
    }
    else
    {
        ret = ctc_dtel_set_property(CTC_DTEL_TEX_CFG,(void*)&tex_cfg);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_set_tix,
        ctc_cli_dtel_set_tix_cmd,
        "dtel tix type (ipfix ) (enable nh-id NH_ID | disable) (eunit-en | )",
        CTC_CLI_DTEL_MODULE,
        "Telemetry informations export",
        "Export type",
        "Ipfix",
        "Enable",
        "Nexthop Id",
        "Nexthop Id Value",
        "Disable",
        "Enalbe on ECPU")
{
    uint8 index = 0;
    int32 ret = CLI_SUCCESS;
    ctc_dtel_tix_cfg_t tix_cfg;

    sal_memset(&tix_cfg, 0, sizeof(ctc_dtel_tix_cfg_t));

    if (CLI_CLI_STR_EQUAL("ipfix", 0))
    {
        tix_cfg.type = CTC_DTEL_TIX_IPFIX;
    }
    else
    {
        return CLI_ERROR;
    }

    if (CLI_CLI_STR_EQUAL("enable", 1))
    {
        CTC_CLI_GET_UINT32("nh id", tix_cfg.nh_id, argv[3]);
    }
    else
    {
        tix_cfg.nh_id = 0;
    }

    index = CTC_CLI_GET_ARGC_INDEX("eunit-en");
    if (0xFF != index)
    {
        tix_cfg.eunit_en = 1;
    }

    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_set_property(g_api_ldev, CTC_DTEL_TIX_CFG,(void*)&tix_cfg);
    }
    else
    {
        ret = ctc_dtel_set_property(CTC_DTEL_TIX_CFG,(void*)&tix_cfg);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_get_tsx,
        ctc_cli_dtel_get_tsx_cmd,
        "show dtel tsx type (mac-stats | drop-stats  | buffer-watermark | latency-watermark | buffer-stats | latency-stats)",
        "Show",
        CTC_CLI_DTEL_MODULE,
        "Telemetry statistics export",
        "Export type",
        "Mac statistics",
        "Drop statistics",
        "Buffer watermark",
        "Latency watermark",
        "Buffer statistics",
        "Latency statistics")
{
    int32 ret = CLI_SUCCESS;
    uint32 idx = 0;
    ctc_dtel_tsx_cfg_t tsx_cfg;

    sal_memset(&tsx_cfg, 0, sizeof(ctc_dtel_tsx_cfg_t));
    if (CLI_CLI_STR_EQUAL("mac-stats", 0))
    {
        tsx_cfg.type = CTC_DTEL_TSX_MAC_STATS;
    }
    else if (CLI_CLI_STR_EQUAL("drop-stats", 0))
    {
        tsx_cfg.type = CTC_DTEL_TSX_DROP_STATS;
    }
    else if (CLI_CLI_STR_EQUAL("buffer-watermark", 0))
    {
        tsx_cfg.type = CTC_DTEL_TSX_BUFFER_WATERMARK;
    }
    else if (CLI_CLI_STR_EQUAL("latency-watermark", 0))
    {
        tsx_cfg.type = CTC_DTEL_TSX_LATENCY_WATERMARK;
    }
    else if (CLI_CLI_STR_EQUAL("buffer-stats", 0))
    {
        tsx_cfg.type = CTC_DTEL_TSX_BUFFER_STATS;
    }
    else if (CLI_CLI_STR_EQUAL("latency-stats", 0))
    {
        tsx_cfg.type = CTC_DTEL_TSX_LATENCY_STATS;
    }
    else
    {
        return CLI_ERROR;
    }

    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_get_property(g_api_ldev, CTC_DTEL_TSX_CFG,(void*)&tsx_cfg);
    }
    else
    {
        ret = ctc_dtel_get_property(CTC_DTEL_TSX_CFG,(void*)&tsx_cfg);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    ctc_cli_out("%-20s: %s\n", "enable", tsx_cfg.enable ? "TRUE" : "FALSE");
    if (tsx_cfg.enable)
    {
        ctc_cli_out("%-20s: %u\n","interval", tsx_cfg.interval);
        ctc_cli_out("%-20s: %u\n", "nh-id", tsx_cfg.nh_id);
        for (idx = 0; idx < CTC_PORT_BITMAP_IN_WORD; idx++)
        {
            if (tsx_cfg.port_bmp[idx])
            {
                ctc_cli_out("Port Bitmap [%d]: 0x%x\n",idx, tsx_cfg.port_bmp[idx]);
            }
        }
    }
    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_get_tex,
        ctc_cli_dtel_get_tex_cmd,
        "show dtel tex type (drop-event | buffer-event | latency-event)",
        "Show",
        CTC_CLI_DTEL_MODULE,
        "Telemetry event export",
        "Export type",
        "Packet drop event",
        "Buffer congestion event",
        "Latency congestion event")
{
    int32 ret = CLI_SUCCESS;
    ctc_dtel_tex_cfg_t tex_cfg;

    sal_memset(&tex_cfg, 0, sizeof(ctc_dtel_tex_cfg_t));
    if (CLI_CLI_STR_EQUAL("drop-event", 0))
    {
        tex_cfg.type = CTC_DTEL_TEX_DROP_EVENT;
    }
    else if (CLI_CLI_STR_EQUAL("latency-event", 0))
    {
        tex_cfg.type = CTC_DTEL_TEX_LATENCY_EVENT;
    }
    else if (CLI_CLI_STR_EQUAL("buffer-event", 0))
    {
        tex_cfg.type = CTC_DTEL_TEX_BUFFER_EVENT;
    }
    else
    {
        return CLI_ERROR;
    }
    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_get_property(g_api_ldev, CTC_DTEL_TEX_CFG,(void*)&tex_cfg);
    }
    else
    {
        ret = ctc_dtel_get_property(CTC_DTEL_TEX_CFG,(void*)&tex_cfg);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    ctc_cli_out("%-20s: %s\n", "enable", tex_cfg.nh_id ? "TRUE" : "FALSE");
    if (tex_cfg.nh_id)
    {
        ctc_cli_out("%-20s: %u\n", "nh-id", tex_cfg.nh_id);
    }

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_get_tix,
        ctc_cli_dtel_get_tix_cmd,
        "show dtel tix type (ipfix )",
        "Show",
        CTC_CLI_DTEL_MODULE,
        "Telemetry informations export",
        "Export type",
        "Ipfix")
{
    int32 ret = CLI_SUCCESS;
    ctc_dtel_tix_cfg_t tix_cfg;
    sal_memset(&tix_cfg, 0, sizeof(ctc_dtel_tix_cfg_t));
    if (CLI_CLI_STR_EQUAL("ipfix", 0))
    {
        tix_cfg.type = CTC_DTEL_TIX_IPFIX;
    }
    else
    {
        return CLI_ERROR;
    }
    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_get_property(g_api_ldev, CTC_DTEL_TIX_CFG,(void*)&tix_cfg);
    }
    else
    {
        ret = ctc_dtel_get_property(CTC_DTEL_TIX_CFG,(void*)&tix_cfg);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    ctc_cli_out("%-20s: %s\n", "enable", tix_cfg.nh_id ? "TRUE" : "FALSE");
    ctc_cli_out("%-20s: %s\n", "eunit_en", tix_cfg.eunit_en ? "TRUE" : "FALSE");
    if (tix_cfg.nh_id)
    {
        ctc_cli_out("%-20s: %u\n", "nh-id", tix_cfg.nh_id);
    }

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_ifa_set_prop,
        ctc_cli_dtel_ifa_set_prop_cmd,
        "dtel ifa (ifa-en (enable|disable) | protocol PROT)",
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_IFA_MODULE,
        "IFA Enable or Disable",
        "Enable",
        "Disable",
        "Protocol",
        "Protocol Value")
{
    int32 ret = CLI_SUCCESS;
    uint8 index = 0;
    ctc_dtel_property_t type = 0;
    uint32 value = 0;


    index = CTC_CLI_GET_ARGC_INDEX("ifa-en");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_IFA_EN;
        if (CLI_CLI_STR_EQUAL("enable", index + 1))
        {
            value = 1;
        }
    }
    index = CTC_CLI_GET_ARGC_INDEX("protocol");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_IFA_PROTOCOL;
        CTC_CLI_GET_UINT8("protocol", value, argv[index + 1]);
    }

    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_set_property(g_api_ldev, type, &value);
    }
    else
    {
        ret = ctc_dtel_set_property(type, &value);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_ifa_set_cfg,
        ctc_cli_dtel_ifa_set_cfg_cmd,
        "dtel ifa session ID node (none|initiator {gns GNS | max-length MAX_LEN | hop-limit HOP_LIMIT | log-percent LOG_PER | req-vec REQ_VEC|} |transit|terminate {nh-id NH_ID|} )",
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_IFA_MODULE,
        "Session",
        "Session ID",
        "Node Type",
        "None Operation",
        "Initiator",
        "GNS",
        "GNS Value",
        "Max Length",
        "Max Length Value",
        "Hop Limit",
        "Hop Limit Value",
        "Log Percent",
        "Log Percent Value",
        "Request Vector",
        "Request Vector Value",
        "Transit",
        "Terminate",
        "Nexthop",
        "Nexthop ID")
{
    int32 ret = CLI_SUCCESS;
    uint8 index = 0;
    ctc_dtel_ifa_cfg_t ifa_cfg;

    sal_memset(&ifa_cfg, 0, sizeof(ctc_dtel_ifa_cfg_t));
    CTC_CLI_GET_UINT8("session id", ifa_cfg.session_id, argv[0]);

    if (CLI_CLI_STR_EQUAL("none", 1))
    {
        ifa_cfg.node = CTC_DTEL_IFA_NODE_NONE;
    }
    else if (CLI_CLI_STR_EQUAL("initiator", 1))
    {
        ifa_cfg.node = CTC_DTEL_IFA_NODE_INITIATOR;
        index = CTC_CLI_GET_ARGC_INDEX("gns");
        if (INDEX_VALID(index))
        {
            CTC_CLI_GET_UINT8("gns", ifa_cfg.gns, argv[index + 1]);
        }
        index = CTC_CLI_GET_ARGC_INDEX("max-length");
        if (INDEX_VALID(index))
        {
            CTC_CLI_GET_UINT8("max length", ifa_cfg.max_length, argv[index + 1]);
        }
        index = CTC_CLI_GET_ARGC_INDEX("hop-limit");
        if (INDEX_VALID(index))
        {
            CTC_CLI_GET_UINT8("hop limit", ifa_cfg.hop_limit, argv[index + 1]);
        }
        index = CTC_CLI_GET_ARGC_INDEX("log-percent");
        if (INDEX_VALID(index))
        {
            CTC_CLI_GET_UINT8("log percent", ifa_cfg.log_percent, argv[index + 1]);
        }
        index = CTC_CLI_GET_ARGC_INDEX("req-vec");
        if (INDEX_VALID(index))
        {
            CTC_CLI_GET_UINT8("reqest vector", ifa_cfg.req_vec, argv[index + 1]);
        }
    }
    else if (CLI_CLI_STR_EQUAL("transit", 1))
    {
        ifa_cfg.node = CTC_DTEL_IFA_NODE_TRANSIT;
    }
    else
    {
        ifa_cfg.node = CTC_DTEL_IFA_NODE_TERMINATE;
        index = CTC_CLI_GET_ARGC_INDEX("nh-id");
        if (INDEX_VALID(index))
        {
            CTC_CLI_GET_UINT32("nh id", ifa_cfg.nh_id, argv[index + 1]);
        }
    }

    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_set_ifa_cfg(g_api_ldev, &ifa_cfg);
    }
    else
    {
        ret = ctc_dtel_set_ifa_cfg(&ifa_cfg);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }

    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_ifa_get_cfg,
        ctc_cli_dtel_ifa_get_cfg_cmd,
        "show dtel ifa session ID",
        "Show",
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_IFA_MODULE,
        "Session",
        "Session ID")
{
    int32 ret = CLI_SUCCESS;
    ctc_dtel_ifa_cfg_t ifa_cfg;

    sal_memset(&ifa_cfg, 0, sizeof(ctc_dtel_ifa_cfg_t));
    CTC_CLI_GET_UINT8("session id", ifa_cfg.session_id, argv[0]);

    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_get_ifa_cfg(g_api_ldev, &ifa_cfg);
    }
    else
    {
        ret = ctc_dtel_get_ifa_cfg(&ifa_cfg);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    switch (ifa_cfg.node)
    {
        case CTC_DTEL_IFA_NODE_NONE:
            ctc_cli_out("%-25s:%s\n", "session node", "none");
            break;
        case CTC_DTEL_IFA_NODE_INITIATOR:
            ctc_cli_out("%-25s:%s\n", "session node", "initiator");
            ctc_cli_out("%-25s:%d\n", "log percent", ifa_cfg.log_percent);
            ctc_cli_out("%-25s:%d\n", "GNS", ifa_cfg.gns);
            ctc_cli_out("%-25s:%d\n", "hop limit", ifa_cfg.hop_limit);
            ctc_cli_out("%-25s:%d\n", "max length", ifa_cfg.max_length);
            ctc_cli_out("%-25s:%d\n", "request vector", ifa_cfg.req_vec);
            break;
        case CTC_DTEL_IFA_NODE_TRANSIT:
            ctc_cli_out("%-25s:%s\n", "session node", "transit");
            break;
        case CTC_DTEL_IFA_NODE_TERMINATE:
            ctc_cli_out("%-25s:%s\n", "session node", "terminate");
            ctc_cli_out("%-25s:%u\n", "nh-id", ifa_cfg.nh_id);
            break;
        default:
            break;
    }
    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_ifa_get_prop,
        ctc_cli_dtel_ifa_get_prop_cmd,
        "show dtel ifa (ifa-en|protocol)",
        "Show",
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_IFA_MODULE,
        "IFA Enable or Disable",
        "Protocol")
{
    int32 ret = CLI_SUCCESS;

    uint8 index = 0;
    ctc_dtel_property_t type = 0;
    uint32 value = 0;


    index = CTC_CLI_GET_ARGC_INDEX("ifa-en");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_IFA_EN;

    }
    index = CTC_CLI_GET_ARGC_INDEX("protocol");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_IFA_PROTOCOL;
    }

    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_get_property(g_api_ldev, type, &value);
    }
    else
    {
        ret = ctc_dtel_get_property(type, &value);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    switch (type)
    {
        case CTC_DTEL_IFA_EN:
            ctc_cli_out("ifa-en:%s\n", value ? "enable" : "disable");
            break;
        case CTC_DTEL_IFA_PROTOCOL:
            ctc_cli_out("protocol:%u\n", value);
            break;
        default:
            break;
    }

    return CLI_SUCCESS;
}
extern int32
sys_usw_dtel_ifa_test_en(uint8 lchip, uint8 enable);
CTC_CLI(ctc_cli_dtel_ifa_test_en,
        ctc_cli_dtel_ifa_test_en_cmd,
        "dtel ifa test-en (enable | disable)",
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_IFA_MODULE,
        "Internal test",
        "Enable",
        "Disable"
        )
{
    uint8 enable = 0;

    if (CLI_CLI_STR_EQUAL("enable", 0))
    {
        enable = 1;
    }

    sys_usw_dtel_ifa_test_en(g_api_lchip, enable);
    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_set_property,
        ctc_cli_dtel_set_property_cmd,
        "dtel property (switch-id SW_ID | int-tnl-dft-session SESSION | \
        int-mode ({(dscp (dscp-value DSCP_VALUE|) | probe-marker PROBE_MARKER (l4-dst-port L4_DST_PORT|)) | l4-chksum-mode L4_CHKSUM_MODE}))",
        CTC_CLI_DTEL_MODULE,
        "Property",
        "Switch id",
        "Switch id value",
        "INT over tunnel decap session",
        "Session ID",
        "INT mode",
        "DSCP mode",
        "DSCP value",
        "DSCP value",
        "Probe marker mode",
        "Probe marker value",
        "Layer4 dest port",
        "Layer4 dest port value",
        "INT L4 chksum mode",
        "0, set l4chksum to 0; 1, not to update; 2, update"
        )
{
    void*  ptr = NULL;
    uint64 value_u64 = 0;
    uint32 value = 0;
    int32 ret = 0;
    uint8 index = 0;
    uint32 type = 0;
    ctc_dtel_int_mode_cfg_t int_mode_cfg;
    
    sal_memset(&int_mode_cfg, 0, sizeof(ctc_dtel_int_mode_cfg_t));
    index = CTC_CLI_GET_ARGC_INDEX("switch-id");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_INTEGER("switch-id", value, argv[index + 1]);
        type = CTC_DTEL_SWITCH_ID;
        ptr = (void*)&value;
    }

    index = CTC_CLI_GET_ARGC_INDEX("int-tnl-dft-session");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_INTEGER("int-tnl-dft-session", value, argv[index + 1]);
        type = CTC_DTEL_INT_TUNNEL_DEFAULT_SESSION_ID;
        ptr = (void*)&value;
    }
    index = CTC_CLI_GET_ARGC_INDEX("int-mode");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_MODE_CFG;
        ptr = (void*)&int_mode_cfg;
        index = CTC_CLI_GET_ARGC_INDEX("probe-marker");
        if (INDEX_VALID(index))
        {
            CTC_CLI_GET_UINT64("probe-marker", value_u64, argv[index + 1]);
            int_mode_cfg.mode = CTC_DTEL_INT_MODE_PROBE_MARKER;
            int_mode_cfg.probe_marker[0] = value_u64 & 0xFFFFFFFF;
            int_mode_cfg.probe_marker[1] = value_u64 >> 32;
        }
        else if (INDEX_VALID(CTC_CLI_GET_ARGC_INDEX("dscp")))
        {
            index = CTC_CLI_GET_ARGC_INDEX("dscp-value");
            if (INDEX_VALID(index))
            {
                CTC_CLI_GET_UINT16("dscp-value", int_mode_cfg.dscp, argv[index + 1]);
            }
            int_mode_cfg.mode = CTC_DTEL_INT_MODE_DSCP;
        }

        if (INDEX_VALID(CTC_CLI_GET_ARGC_INDEX("l4-chksum-mode")))
        {
            index = CTC_CLI_GET_ARGC_INDEX("l4-chksum-mode");
            CTC_CLI_GET_UINT8("l4-chksum-mode", int_mode_cfg.l4_chksum_mode, argv[index + 1]);
        }
        index = CTC_CLI_GET_ARGC_INDEX("l4-dst-port");
        if (INDEX_VALID(index))
        {
            CTC_CLI_GET_UINT16("l4-dst-port", int_mode_cfg.l4_dest_port, argv[index + 1]);
        }
    }
    
    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_set_property(g_api_ldev, type, ptr);
    }
    else
    {
        ret = ctc_dtel_set_property(type, ptr);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_get_property,
        ctc_cli_dtel_get_property_cmd,
        "show dtel property (switch-id | int-tnl-dft-session | int-mode)",
        "Show",
        CTC_CLI_DTEL_MODULE,
        "Property",
        "Switch id",
        "INT over tunnel decap session",
        "INT mode")
{
    void* ptr = NULL;
    uint32 value = 0;
    int32 ret = 0;
    uint32 type = 0;
    uint8 index = 0;
    ctc_dtel_int_mode_cfg_t int_mode_cfg;

    sal_memset(&int_mode_cfg, 0, sizeof(ctc_dtel_int_mode_cfg_t));
    index = CTC_CLI_GET_ARGC_INDEX("switch-id");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_SWITCH_ID;
        ptr = (void*)&value;
    }
    
    index = CTC_CLI_GET_ARGC_INDEX("int-tnl-dft-session");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_TUNNEL_DEFAULT_SESSION_ID;
        ptr = (void*)&value;
    }
    index = CTC_CLI_GET_ARGC_INDEX("int-mode");
    if (INDEX_VALID(index))
    {
        type = CTC_DTEL_INT_MODE_CFG;
        ptr = (void*)&int_mode_cfg;
    }
    
    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_get_property(g_api_ldev, type, ptr);
    }
    else
    {
        ret = ctc_dtel_get_property(type, ptr);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    switch (type)
    {
        case CTC_DTEL_SWITCH_ID:
            ctc_cli_out("%-20s:0x%x\n", "switch-id", value);
            break;
        case CTC_DTEL_INT_MODE_CFG:
            ctc_cli_out("%-20s: %s\n", "int-mode", (CTC_DTEL_INT_MODE_DSCP == int_mode_cfg.mode) ? "dscp" : "probe-marker");
            if (CTC_DTEL_INT_MODE_PROBE_MARKER == int_mode_cfg.mode)
            {
                ctc_cli_out("%-20s:0x%08x%08x\n", "probe-marker", int_mode_cfg.probe_marker[1], int_mode_cfg.probe_marker[0]);
                ctc_cli_out("%-20s:0x%x\n", "l4-dest-port", int_mode_cfg.l4_dest_port);
            }
            else
            {
                ctc_cli_out("%-20s:0x%x\n", "dscp-value", int_mode_cfg.dscp);
            }

            if (2 == int_mode_cfg.l4_chksum_mode)
            {
                ctc_cli_out("%-20s:%s\n", "l4-chksum-mode", " update");
            }
            else if (1 == int_mode_cfg.l4_chksum_mode)
            {
                ctc_cli_out("%-20s:%s\n", "l4-chksum-mode", " not-update");
            }
            else
            {
               ctc_cli_out("%-20s:%s\n", "l4-chksum-mode", " set-zero");
            }
            break;
        case CTC_DTEL_INT_TUNNEL_DEFAULT_SESSION_ID:
            ctc_cli_out("%s:%u\n", "int-tnl-dft-session", value);
            break;
        default:
            break;
    }
    return CLI_SUCCESS;
}

CTC_CLI(ctc_cli_dtel_ifa_set_mode_cfg,
        ctc_cli_dtel_ifa_set_mode_cfg_cmd,
        "dtel ifa {ifa-ver VERSION | req-vec REQ_VEC}",
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_IFA_MODULE,
        "IFA Version",
        "IFA Version",
        "Request Vector",
        "Request Vector Array")
{
    int32 ret = CLI_SUCCESS;
    uint8 index = 0;
    ctc_dtel_property_t type = CTC_DTEL_IFA_MODE_CFG;
    ctc_dtel_ifa_mode_cfg_t mode_cfg;
    uint32 num = CTC_DTEL_IFA_REQ_VEC_BIT_NUM;
    
    sal_memset(&mode_cfg, 0, sizeof(ctc_dtel_ifa_mode_cfg_t));
    
    index = CTC_CLI_GET_ARGC_INDEX("ifa-ver");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_UINT8("ifa-ver", mode_cfg.version, argv[index+1]);
    }

    index = CTC_CLI_GET_ARGC_INDEX("req-vec");
    if (INDEX_VALID(index))
    {
        CTC_CLI_GET_UINT8_ARRAY(argv[index+1], mode_cfg.req_vec, &num, argv[index+1], ret);
    }

    if (ret != CLI_SUCCESS)
    {
        return CLI_ERROR;
    }

    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_set_property(g_api_ldev, type,(void*)&mode_cfg);
    }
    else
    {
        ret = ctc_dtel_set_property(type,(void*)&mode_cfg);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    return CLI_SUCCESS;
}


CTC_CLI(ctc_cli_dtel_ifa_get_mode_cfg,
        ctc_cli_dtel_ifa_get_mode_cfg_cmd,
        "show dtel ifa ifa-mode",
        "Show",
        CTC_CLI_DTEL_MODULE,
        CTC_CLI_IFA_MODULE,
        "IFA Mode cfg")
{
    int32 ret = CLI_SUCCESS;
    ctc_dtel_property_t type = CTC_DTEL_IFA_MODE_CFG;
    ctc_dtel_ifa_mode_cfg_t mode_cfg;
    uint8 loop = 0;
    sal_memset(&mode_cfg, 0, sizeof(ctc_dtel_ifa_mode_cfg_t));

    if(g_ctcs_api_en)
    {
        ret = ctcs_dtel_get_property(g_api_ldev, type, (void*)&mode_cfg);
    }
    else
    {
        ret = ctc_dtel_get_property(type, (void*)&mode_cfg);
    }
    if (ret < 0)
    {
        ctc_cli_out("%% %s \n", ctc_get_error_desc(ret));
        return CLI_ERROR;
    }
    ctc_cli_out("%-20s:%d\n", "ifa-version", mode_cfg.version);
    ctc_cli_out("%-20s:", "req_vec");
    for(loop = 0; loop < CTC_DTEL_IFA_REQ_VEC_BIT_NUM-1; ++loop)
    {
        ctc_cli_out("0x%x\t", mode_cfg.req_vec[loop]);
    }
    ctc_cli_out("\n");
    return CLI_SUCCESS;
}


int32
ctc_usw_dtel_cli_init(void)
{
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_int_set_sink_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_show_int_sink_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_show_int_status_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_debug_on_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_debug_off_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_set_int_cfg_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_set_int_act_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_get_int_cfg_cmd);

    install_element(CTC_SDK_MODE, &ctc_cli_dtel_set_tsx_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_get_tsx_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_set_tex_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_get_tex_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_set_tix_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_get_tix_cmd);

    install_element(CTC_SDK_MODE, &ctc_cli_dtel_ifa_set_prop_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_ifa_get_prop_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_ifa_get_cfg_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_ifa_set_cfg_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_ifa_get_mode_cfg_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_ifa_set_mode_cfg_cmd);
    install_element(CTC_INTERNAL_MODE, &ctc_cli_dtel_ifa_test_en_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_set_property_cmd);
    install_element(CTC_SDK_MODE, &ctc_cli_dtel_get_property_cmd);
    return 0;
}

int32
ctc_usw_dtel_cli_deinit(void)
{
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_int_set_sink_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_show_int_sink_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_show_int_status_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_debug_on_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_debug_off_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_set_int_cfg_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_set_int_act_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_get_int_cfg_cmd);

    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_set_tsx_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_get_tsx_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_set_tex_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_get_tex_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_set_tix_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_get_tix_cmd);

    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_ifa_set_prop_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_ifa_get_prop_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_ifa_get_cfg_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_ifa_set_cfg_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_ifa_get_mode_cfg_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_ifa_set_mode_cfg_cmd);
    uninstall_element(CTC_INTERNAL_MODE, &ctc_cli_dtel_ifa_test_en_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_set_property_cmd);
    uninstall_element(CTC_SDK_MODE, &ctc_cli_dtel_get_property_cmd);
    return 0;
}

#endif

